// 引入接口地址
import { cateList } from "@/request/api"

// 菜单仓库模块
const state = {
    cateList: [],
}

const mutations = {
    REQ_CATELIST(state, payload) {
        return state.cateList = payload
    }
}

const actions = {
    getCateList_Action({ commit }) {
        // 调用商品分类列表接口
        cateList({
            istree: true
        }).then(res => {
            console.log(res);
            if (res.code == 200) {
                commit("REQ_CATELIST", res.list)
            }
        })
    }
}

const getters = {
    getCateList(state) {
        return state.cateList
    }
}

// 导出菜单仓库
export default {
    state,
    mutations,
    actions,
    getters,
    namespaced: true
}